#ifndef SEARCHLIST_H
#define SEARCHLIST_H

#include "userdata.h"

#include <QListWidget>

class LoadingDlg;

// 联系人列表类
class SearchList : public QListWidget
{
    Q_OBJECT
public:
    SearchList(QWidget *parent = nullptr);

    // 清除弹出的添加好友框
    void clearFindDlg();
    void setSearchEdit(QWidget* edit);
    void closeFindDlg();

protected:
    bool eventFilter(QObject *object, QEvent *event) override;

private:
    void addTipItem();
    // 等待发送查找联系人之后的后端处理
    void waitPending(bool pending = true);

signals:
    // 好友申请界面跳转到聊天界面的信号
    void sig_jump_chat_item(std::shared_ptr<SearchInfo> search_info);

public slots:
    // 处理联系人条目被点击的信号
    void slot_item_clicked(QListWidgetItem* item);
    // 处理搜索联系人的信号
    void slot_user_search(std::shared_ptr<SearchInfo> search_info);

private:
    bool m_send_pending; // 当前UI界面是否等待的标识符
    QWidget* m_search_edit;
    std::shared_ptr<QDialog> m_find_dlg;
    LoadingDlg* m_loadingDialog;
};

#endif // SEARCHLIST_H
